﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Configuration;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("KylinORM.Data")]
[assembly: InternalsVisibleTo("KylinORM.Message")]
namespace KylinORM.Utils
{
    /// <summary>
    /// 配置管理器
    /// </summary>
    internal abstract class ConfigManager
    {
        #region 内部属性
        private static Configuration config;

        static ConfigManager()
        {
            string dllPath = Assembly.GetExecutingAssembly().CodeBase.Substring(8);
            config = ConfigurationManager.OpenExeConfiguration(dllPath);
        }

        protected static AppSettingsSection AppSettings { get { return config.AppSettings; } }
        protected static ConnectionStringsSection ConnectionStrings { get { return config.ConnectionStrings; } }
        #endregion

        /// <summary>
        /// 默认数据访问类
        /// </summary>
        internal static Type DefaultDataProvider
        {
            get
            {
                return Type.GetType(AppSettings.Settings["DefaultDataProvider"].Value);
            }
        }

        /// <summary>
        /// 默认消息访问类
        /// </summary>
        internal static Type DefaultMessageProvider
        {
            get
            {
                return Type.GetType(AppSettings.Settings["DefaultMessageProvider"].Value);
            }
        }

        /// <summary>
        /// 默认数据服务器
        /// </summary>
        internal static string DefaultDataServer
        {
            get
            {
                return ConnectionStrings.ConnectionStrings["DefaultDataServer"].ConnectionString;
            }
        }

        /// <summary>
        /// 默认消息服务器
        /// </summary>
        internal static string DefaultMessageServer
        {
            get
            {
                return ConnectionStrings.ConnectionStrings["DefaultMessageServer"].ConnectionString;
            }
        }

    }
}
